package ferp.android.views.table.element.text;

import android.content.Context;
import android.graphics.Rect;
import android.view.Gravity;
import android.widget.TextView;
import ferp.android.GUI;
import ferp.android.R;
import ferp.android.views.table.TableView;
import ferp.android.views.table.element.Element;
import ferp.core.game.Game;

/**
 * User: olegs
 * Date: 04/01/2015 21:17
 */
public class Watermark extends Element<TextView>
{
  public Watermark(Context context, TableView parent) {super(context, parent);}

  public void show(Rect area, Game g)
  {
    if (g.replay || g.tutorial())
    {
      view.setText(g.replay ? R.string.dialog_pool_replay_noun : R.string.tutorial_watermark);
      show(area);
    }
    else
      show(false);
  }

  @Override
  protected final TextView create(Context context, TableView parent)
  {
    TextView tv = new TextView(context);

    tv.setGravity(Gravity.CENTER);
    tv.setTypeface(GUI.Font.NORMAL);
    tv.setTextColor(GUI.Color.WATERMARK_TABLE);
    tv.setShadowLayer(1, 1, 1, 0xFFFFFFFF);

    return tv;
  }

  @Override
  protected final void onBeforeLayout(Rect area) {GUI.FitText.byFactors(view, 0.8f, 0.5f);}
}
